package com.cn.xiaonuo.slbfinances.slcoupon.controller;

import cn.hutool.core.convert.Convert;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.common.utils.ApiJsonModel;
import com.cn.xiaonuo.slbfinances.slcoupon.service.IGzCouponService;
import com.cn.xiaonuo.slbfinances.slcoupon.service.IHpcCouponService;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@RestController
public class CouponController {

    @Resource
    private IGzCouponService gzCouponService;
    @Resource
    private IHpcCouponService hpcCouponService;

    @ApiOperation(value = "购物券管理-搜了宝购物收支记录-国甄购物券收支记录", notes = "购物券管理-搜了宝购物收支记录-国甄购物券收支记录")
    @ApiJsonModel({
            @ApiModelProperty(name = "checkState", value = "检查状态"),
            @ApiModelProperty(name = "userId", value = "用户ID"),
            @ApiModelProperty(name = "phone", value = "用户电话号码"),
            @ApiModelProperty(name = "pageNo", value = "页数", required = true),
            @ApiModelProperty(name = "pageSize", value = "长度", required = true)
    })
    @RequestMapping(value = "/api/coupons/qryUserGzBalance", method = RequestMethod.POST)
    public BusinessMessage qryUserGzBalance(String checkState, String userId, String phone, Integer pageNo, Integer pageSize) {
        return gzCouponService.qryUserGzBalance(checkState, userId, phone, pageNo, pageSize);
    }
    @ApiOperation(value = "购物券管理-搜了宝购物收支记录-和平村购物券收支记录", notes = "购物券管理-搜了宝购物收支记录-和平村购物券收支记录")
    @ApiJsonModel({
            @ApiModelProperty(name = "userId", value = "用户ID"),
            @ApiModelProperty(name = "beginTime", value = "开始时间"),
            @ApiModelProperty(name = "endTime", value = "结束时间"),
            @ApiModelProperty(name = "pageNo", value = "页数", required = true),
            @ApiModelProperty(name = "pageSize", value = "长度", required = true)
    })
    @PostMapping(value = "/api/coupons/selectGwjInfo")
    public BusinessMessage selectGwjInfo(@RequestBody Map<String,Object> params) {
        String userId= Convert.toStr(params.get("userId"));
        Long beginTime= Convert.toLong(params.get("beginTime"));
        Long endTime= Convert.toLong(params.get("endTime"));
        Integer pageNo=Convert.toInt(params.get("pageNo"));
        Integer pageSize=Convert.toInt(params.get("pageSize"));
        return hpcCouponService.selectGwjInfo(userId,beginTime,endTime,pageNo,pageSize);
    }

    @ApiOperation(value = "购物券管理-搜了宝购物收支记录", notes = "购物券管理-搜了宝购物收支记录")
    @ApiJsonModel({
            @ApiModelProperty(name = "userId", value = "用户ID",example = "10086"),
            @ApiModelProperty(name = "beginTime", value = "开始时间",example = "012122222l"),
            @ApiModelProperty(name = "endTime", value = "结束时间",example = "9898888888l"),
            @ApiModelProperty(name = "pageNo", value = "页数", example ="1",required = true),
            @ApiModelProperty(name = "pageSize", value = "长度", example ="10",required = true)
    })
    @RequestMapping(value = "/api/coupons/selectGwjInfoOut", method = RequestMethod.POST)
    public BusinessMessage selectGwjInfoOut(String userId, Long beginTime, Long endTime, Integer pageNo, Integer pageSize){
        return gzCouponService.selectGwjInfoOut(userId,beginTime,endTime,pageNo,pageSize);
    }

    @ApiOperation(value = "购物券管理-搜了宝购物收支记录-搜了宝购物券收支记录", notes = "购物券管理-搜了宝购物收支记录-搜了宝购物券收支记录")
    @ApiJsonModel({
            @ApiModelProperty(name = "userId", value = "用户ID",example = "10086"),
            @ApiModelProperty(name = "beginTime", value = "开始时间",example = "012122222l"),
            @ApiModelProperty(name = "endTime", value = "结束时间",example = "9898888888l"),
            @ApiModelProperty(name = "pageNo", value = "页数", example ="1",required = true),
            @ApiModelProperty(name = "pageSize", value = "长度", example ="10",required = true)
    })
    @RequestMapping(value = "/api/coupons/selectGwjInfoIn", method = RequestMethod.POST)
    public BusinessMessage selectGwjInfoIn(String userId, Long beginTime, Long endTime, Integer pageNo, Integer pageSize){
        return gzCouponService.selectGwjInfoIn(userId,beginTime,endTime,pageNo,pageSize);
    }

}
